I have a module I use for reporting. That module is constructed as an index of the other modules in our database, with each object used to represent each corresponding module. |
Re: How do I omit / filter / disgard repeated attribute information? Well the answer is indeed skip lists. You can read a bit about skips in the DXL help to get a more firm understanding, the major behaviour is, that they store key/value pairs, where the keys must be unique. So for one key, you can only have one value in a skip. So the idea to remove redundancy in your output is, to add each line to a skip, before putting it to the result. If the order of the item is important, you will only use the skip for checking if the line is already in the result.
// global variables to store the result
Buffer bufResult = create()
Skip skLines = createString() // when the skip stores string keys, then use 'createString' to create it
void clearResult () {
bufResult = ""
setempty skLines
}
void addToResult (string s) {
// if the item is already in the skip, do not add again
if (find(skLines, s)) return
if (length bufResult > 0) bufResult += "\n"
bufResult += s
// add the item to the skip
put (skLines, s, 0)
}
addToResult ("Hello!")
addToResult ("World!")
addToResult ("Hello!")
addToResult ("(and Skips!)")
print stringOf bufResult
Since Skips have the nice property of sorting alphabetically you can also just put stuff to the Skip and later read it back from there:
// global variables to store the result
Skip skLines = createString() // when the skip stores string keys, then use 'createString' to create it
void clearResult () {
setempty skLines
}
Buffer getResult () {
Buffer buf = create();
// get the items sorted from the skip
string s; for s in skLines do {
if (length buf > 0) buf += "\n"
buf += s
}
return buf
}
void addToResult (string s) {
// if the item is already in the skip, do not add again
if (find(skLines, s)) return
// add the item to the skip
put (skLines, s, s)
}
addToResult ("Hello!")
addToResult ("World!")
addToResult ("Hello!")
addToResult ("(and Skips!)")
print stringOf getResult()
Note how in both example the duplicate item 'Hello!' is filtered from the result. Hope that helps, Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: How do I omit / filter / disgard repeated attribute information? |
Re: How do I omit / filter / disgard repeated attribute information? Mathias Mamsch - Tue Sep 04 11:51:41 EDT 2012 Well the answer is indeed skip lists. You can read a bit about skips in the DXL help to get a more firm understanding, the major behaviour is, that they store key/value pairs, where the keys must be unique. So for one key, you can only have one value in a skip. So the idea to remove redundancy in your output is, to add each line to a skip, before putting it to the result. If the order of the item is important, you will only use the skip for checking if the line is already in the result.
// global variables to store the result
Buffer bufResult = create()
Skip skLines = createString() // when the skip stores string keys, then use 'createString' to create it
void clearResult () {
bufResult = ""
setempty skLines
}
void addToResult (string s) {
// if the item is already in the skip, do not add again
if (find(skLines, s)) return
if (length bufResult > 0) bufResult += "\n"
bufResult += s
// add the item to the skip
put (skLines, s, 0)
}
addToResult ("Hello!")
addToResult ("World!")
addToResult ("Hello!")
addToResult ("(and Skips!)")
print stringOf bufResult
Since Skips have the nice property of sorting alphabetically you can also just put stuff to the Skip and later read it back from there:
// global variables to store the result
Skip skLines = createString() // when the skip stores string keys, then use 'createString' to create it
void clearResult () {
setempty skLines
}
Buffer getResult () {
Buffer buf = create();
// get the items sorted from the skip
string s; for s in skLines do {
if (length buf > 0) buf += "\n"
buf += s
}
return buf
}
void addToResult (string s) {
// if the item is already in the skip, do not add again
if (find(skLines, s)) return
// add the item to the skip
put (skLines, s, s)
}
addToResult ("Hello!")
addToResult ("World!")
addToResult ("Hello!")
addToResult ("(and Skips!)")
print stringOf getResult()
Note how in both example the duplicate item 'Hello!' is filtered from the result. Hope that helps, Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Once again you've dazzled me. I truly appreciate it. And adding the new line to address my formatting. It's almost too much. Thanks again! |